#ifndef _FONTGLYPH_H_
#define _FONTGLYPH_H_

namespace Font
{

	// char id=171  
	// x=79    
	// y=122   
	// width=9     
	// height=10    
	// xoffset=1     
	// yoffset=9     
	// xadvance=11    
	// page=0  
	// chnl=15

	class Glyph
	{

		friend class Glyph;
	
	public:
	
		Glyph(Library* a_Library);
		~Glyph();

		void SetProperties(wchar_t a_Character, const tb::Pos2& a_Position, const tb::Pos2& a_Advance);
		void SetBitmap(unsigned int a_Width, unsigned int a_Height, unsigned int a_BitDepth);
		unsigned char* GetBitmapData();
		unsigned int GetBitmapArea();
		bool CheckBitmapValid();
		void CalculateBoundingBox();
		const wchar_t& GetCharacter();

		bool CheckValid();

		const tb::Pos2& GetPos() { return m_Position; }
		int GetPosYMax() { return m_PosYMax; }
		const tb::Pos2& GetBearing() { return m_Bearing; }
		const tb::Pos2& GetAdvance() { return m_Advance; }
		const tb::Pos2& GetDimensions() { return m_Dimensions; }

		const tb::Pos2& GetBitmapDimensions() { return m_BitmapDimensions; }
		unsigned int GetBitmapWidth() { return m_BitmapDimensions.x; }
		unsigned int GetBitmapHeight() { return m_BitmapDimensions.y; }

		const tb::Vec2& GetBoundingBoxStart() { return m_BoundingBoxStart; }
		const tb::Vec2& GetBoundingBoxEnd() { return m_BoundingBoxEnd; }

	protected:

		tb::Pos2 m_Position;
		tb::Pos2 m_Advance;

		wchar_t m_Character;

		int m_PosYMax;
		tb::Pos2 m_Dimensions;
		tb::Pos2 m_Bearing;

		tb::Pos2 m_Offset;

		tb::Vec2 m_BoundingBoxStart, m_BoundingBoxEnd;

		unsigned char* m_BitmapData;
		tb::Pos2 m_BitmapDimensions;
		unsigned int m_BitmapArea;

		Library* m_Library;
	
	}; // class Glyph

	struct GlyphEntry
	{
		Glyph* glyph;
		bool bitmap;
		tb::Pos2 cursor;
		tb::Vec2 pos_start, pos_end;
		tb::Vec2 tex_start, tex_end;
		tb::Vec2 dimensions;
		float advance;
		int page_id;
	};

}; // namespace Font
	
#endif